﻿Public Class PickForm

    Public mf As MatchingFile
    Public newList As New ArrayList


    Private Sub PickForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load


        Me.dgvNewList.Rows.Clear()

        For Each item As String In mf.filePath
            Dim dgvr As New DataGridViewRow

            ' 選択
            Dim cellSelect As New DataGridViewCheckBoxCell()
            cellSelect.Value = False

            dgvr.Cells.Add(cellSelect)

            ' ファイル名
            Dim cellFileName As New DataGridViewTextBoxCell()
            cellFileName.Value = mf.fileName
            dgvr.Cells.Add(cellFileName)

            ' ファイルフールパス
            Dim cellFileFullPath As New DataGridViewTextBoxCell()
            cellFileFullPath.Value = item
            dgvr.Cells.Add(cellFileFullPath)

            Me.dgvNewList.Rows.Add(dgvr)
        Next


    End Sub

    Private Sub btnExcute_Click(sender As Object, e As EventArgs) Handles btnExcute.Click

        Me.newList = New ArrayList
        For rowIndex As Integer = 0 To Me.dgvNewList.Rows.Count - 1

            Dim cell As DataGridViewCell = Me.dgvNewList.Rows(rowIndex).Cells(0)
            If cell.Value = True Then
                Dim mf As New MatchingFile

                mf.fileName = Me.dgvNewList.Rows(rowIndex).Cells(1).Value

                mf.filePath.Add(Me.dgvNewList.Rows(rowIndex).Cells(2).Value)

                Me.newList.Add(mf)
            End If

        Next

        If Me.newList.Count = 0 Then
            MsgBox("must be select one!")
        Else
            Me.Close()
        End If

    End Sub

    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub
End Class